from typing import List


def sortArrayByParity(self, nums: List[int]) -> List[int]:
    slow ,fast = 0,len(nums)-1
    while slow < fast :
        if nums[fast] %2 ==0 and nums[slow] %2 !=0:
            nums[slow],nums[fast] = nums[fast],nums[slow]
            slow+=1
            fast-=1
        elif nums[fast] % 2 == 0 and nums[slow] % 2 == 0:
            slow+=1
        else:
            fast-=1
    return nums